package com.xw.controller;


import com.xw.mapper.Mymapper;
import com.xw.pojo.User02;
import com.xw.service.Service;
import jakarta.servlet.http.HttpSession;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("my")
public class Controller {
    @Autowired
    private Mymapper mymapper;

    @Autowired
    private Service service;
    private int count;
    private  static  final  Logger logger = LoggerFactory.getLogger(ControolerJDBC.class);


    @GetMapping ("find") //发起get请求
    public Object find(String id)  {

        String rs= mymapper.findstu(id);
        HashMap data = new HashMap();
        data.put("你的姓名是：",rs);
        System.out.println("我被访问了次");
        return   data;
    }

    //路径传参以及session保存数据
    @GetMapping ("{id}")
    public Object findid(HttpSession session, @PathVariable  String id){

        logger.info("我接收的参数是："+id);
        String rs= mymapper.findstu(id);
        HashMap data = new HashMap();
        data.put("你的姓名是：",rs);
        System.out.println("我被访问了次");
        logger.info("我响应的数据是：："+data);
       session.setAttribute("user",rs);
        logger.info("Session存了：{}"+session.getAttribute("user"));
        return data;
    }
}
